package com.ytjj.qmyx.data.controller;

import com.ytjj.common.api.CommonResult;
import com.ytjj.common.constants.QueueConstants;
import com.ytjj.common.dto.mqdto.SmsDto;
import com.ytjj.qmyx.data.mapper.OrdersDao;
import com.ytjj.qmyx.mall.model.Orders;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author jiawei
 * @date 2023年04月12日 11:37
 * @describe
 */
@Slf4j
@RestController
@RequestMapping("/callback")
public class CallbackController {

    @Resource
    private OrdersDao ordersDao;
    @Resource
    RabbitTemplate rabbitTemplate;

    /**
     * 测试接口
     */
    @GetMapping("/testData")
    public CommonResult testData(){
        return CommonResult.success("OK");
    }

    /**
     * 手动发短信
     */
//    @PostMapping("/manuallySendSms")
//    public CommonResult manuallySendSms(String startTime,String endTime,String content){
//        List<Orders> orderList = ordersDao.getIsPayByTime(startTime, endTime);
//        log.info("======开始手动补发短信,共："+orderList.size()+"条");
//        orderList.stream().forEach(e -> {
//            SmsDto smsDto = new SmsDto();
//            smsDto.setPhone(e.getUserPhone());
//            smsDto.setType(7);
//            smsDto.setCode(content);
//            smsDto.setChannel(e.getChannel());
//            smsDto.setOrderSource(e.getOrderSource());
//            smsDto.setDomainUrl(e.getDomainUrl());
//            smsDto.setToken(e.getH5Token());
//            rabbitTemplate.convertAndSend(QueueConstants.SMS_QUEUE, smsDto);
//        });
//        return CommonResult.success();
//    }

}
